<?php
/**
 * Digg pagination style
 * 
 * @preview  « Previous  1 2 … 5 6 7 8 9 10 11 12 13 14 … 25 26  Next »
 */
    $page = Zend_Controller_Front::getInstance()->getRequest()->getParam('page');
    
    $this->total_items        = (int) max(0, $this->totalItemCount);
    $this->items_per_page     = (int) max(1, $this->itemCountPerPage);
    $this->total_pages        = (int) ceil($this->total_items / $this->items_per_page);
    $this->current_page       = (int) min(max(1, $page), max(1, $this->total_pages));
    $this->current_first_item = (int) min((($this->current_page - 1) * $this->items_per_page) + 1, $this->total_items);
    $this->current_last_item  = (int) min($this->current_first_item + $this->items_per_page - 1, $this->total_items);

    // If there is no first/last/previous/next page, relative to the
    // current page, value is set to FALSE. Valid page number otherwise.
    $this->first_page         = ($this->current_page == 1) ? FALSE : 1;
    $this->last_page          = ($this->current_page >= $this->total_pages) ? FALSE : $this->total_pages;
    $this->previous_page      = ($this->current_page > 1) ? $this->current_page - 1 : FALSE;
    $this->next_page          = ($this->current_page < $this->total_pages) ? $this->current_page + 1 : FALSE;


?>




<div class="bar corner-all paginator">
     <ul class="paginator-content paginator-background-spr line-background">
     <li>
	<?php if ($this->previous_page): ?>
		<a class="paginator-background-spr previous-page" href="<?php echo $this->curl(array('page' => $this->previous_page)); ?>"></a>
	<?php else: ?>
		
		<a class="paginator-background-spr previous-page" href="" onclick="return false;"></a>
	<?php endif ?>
	</li>

	<?php if ($this->total_pages < 11): /* « Previous  1 2 3 4 5 6 7 8 9 10 11 12  Next » */ ?>

		<?php for ($i = 1; $i <= $this->total_pages; $i++): ?>
			<?php if ($i == $this->current_page): ?>
				<li class="active"><a class="paginator-background-spr s-active-bg" href="" onclick="return false;"><?php echo $i ?></a> <span></span></li>
			<?php else: ?>
				<li><a href="<?php echo $this->curl(array('page' => $i)); ?>"><?php echo $i ?></a><span></span></li>
			<?php endif ?>
		<?php endfor ?>

	<?php elseif ($this->current_page < 7): /* « Previous  1 2 3 4 5 6 7 8 9 10 … 25 26  Next » */ ?>

		<?php for ($i = 1; $i <= 8; $i++): ?>
			<?php if ($i == $this->current_page): ?>
				<li class="active"><a class="paginator-background-spr s-active-bg" href="" onclick="return false;"><?php echo $i ?></a> <span></span></li>
			<?php else: ?>
				<li><a href="<?php echo $this->curl(array('page' => $i)); ?>"><?php echo $i ?></a><span></span></li>
			<?php endif ?>
		<?php endfor ?>

		<li class="paginator-background-spr dotted"></li>
		<li><a href="<?php echo $this->curl(array('page' => $this->total_pages - 1)); ?>"><?php echo $this->total_pages - 1 ?></a><span></span></li>
		<li><a href="<?php echo $this->curl(array('page' => $this->total_pages)); ?>"><?php echo $this->total_pages ?></a><span></span></li>

	<?php elseif ($this->current_page > $this->total_pages - 6): /* « Previous  1 2 … 17 18 19 20 21 22 23 24 25 26  Next » */ ?>

		<li><a href="<?php echo $this->curl(array('page' => 1)); ?>">1</a><span></span></li>
		<li><a href="<?php echo $this->curl(array('page' => 2)); ?>">2</a><span></span></li>
		<li class="paginator-background-spr dotted"></li>

		<?php for ($i = $this->total_pages - 7; $i <= $this->total_pages; $i++): ?>
			<?php if ($i == $this->current_page): ?>
				<li class="active"><a class="paginator-background-spr s-active-bg" href="" onclick="return false;"><?php echo $i ?></a> <span></span></li>
			<?php else: ?>
			<li><a href="<?php echo $this->curl(array('page' => $i)); ?>"><?php echo $i ?></a><span></span></li>
			<?php endif ?>
		<?php endfor ?>

	<?php else: /* « Previous  1 2 … 5 6 7 8 9 10 11 12 13 14 … 25 26  Next » */ ?>

		<li><a href="<?php echo $this->curl(array('page' => 1)); ?>">1</a><span></span></li>
		<li><a href="<?php echo $this->curl(array('page' => 2)); ?>">2</a></a><span></span></li>
		<li class="paginator-background-spr dotted"></li>

		<?php for ($i = $this->current_page - 4; $i <= $this->current_page + 4; $i++): ?>
			<?php if ($i == $this->current_page): ?>
				<li class="active"><a class="paginator-background-spr s-active-bg" href="" onclick="return false;"><?php echo $i ?></a> <span></span></li>
			<?php else: ?>
				<li><a href="<?php echo $this->curl(array('page' => $i)); ?>"><?php echo $i ?></a><span></span></li>
			<?php endif ?>
		<?php endfor ?>

		<li class="paginator-background-spr dotted"></li>
		<li><a href="<?php echo $this->curl(array('page' => $this->total_pages - 1)); ?>"><?php echo $this->total_pages - 1 ?></a><span></span></li>
		<li><a href="<?php echo $this->curl(array('page' => $this->total_pages )); ?>"><?php echo $this->total_pages ?></a><span></span></li>

	<?php endif ?>

	<li class="last">
	<?php if ($this->next_page): ?>
		<a class="paginator-background-spr next-page" href="<?php echo $this->curl(array('page' => $this->next_page)); ?>"></a>
	<?php else: ?>
		<a class="paginator-background-spr next-page" onclick="return false;" href="<?php echo $this->curl(array('page' => $this->next_page)); ?>"></a>
	<?php endif ?>
	</li>
	
	</ul>
</div>